package cn.sportvip.entity.user;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import cn.sportvip.entity.TimestampEntity;
/**
 * 用户验证信息，登陆时候用,邮箱登陆或者电话号码登陆
 * @author tao
 */
@Entity
@Table(name = "user_credential")
public class Credential extends TimestampEntity{
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(generator = "SharedPrimaryKeyGenerator")
	@GenericGenerator(name = "SharedPrimaryKeyGenerator", strategy = "foreign", parameters = { @Parameter(name = "property", value = "userInfo") })
	private Integer id;
	
	@Column(unique = true, nullable = false)
	private String email;
	@Column(unique = true, nullable = false)
	private String phone;
	@Column(nullable = false)
	private String password;
	@OneToOne(targetEntity = UserInfo.class, cascade = CascadeType.ALL, optional = false)
	@PrimaryKeyJoinColumn
	private UserInfo userInfo;
		
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public UserInfo getUserInfo() {
		return userInfo;
	}
	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}
}
